package hiresoft.ui;

import hiresoft.users.User;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/**
 * Creates relationship between UI classes
 *
 * @author Jan Jorgensen
 */
public abstract class UserFrame extends JFrame {
    protected User user;
    protected LoginFrame context;

    public UserFrame(LoginFrame _context, User _user){
        user = _user;
        context = _context;

        JMenuBar mbar = new JMenuBar();
        JMenu file = new JMenu("File");
        JMenuItem logout = new JMenuItem("Log out");
        mbar.add(file);
        file.add(logout);
        setJMenuBar(mbar);

        logout.addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e) {
                logout();
            }
        });


    }

    protected void logout(){
            context.setVisible(true);
            this.setVisible(false);
            context.clearFields();
        }
}
